local assets =
{
    Asset("ANIM", "anim/campfire_fire.zip"),
    Asset("SOUND", "sound/common.fsb"),
}

local prefabs =
{
    "firefx_light",
}

local LIGHT_COLOUR = RGB(255, 99, 71)

--------------------------------------------------------------------------

local candlefirelevels =
{
    { anim = "level1", sound = "dontstarve/common/campfire", radius = 1, intensity = 0.8, falloff = 0.33, colour = LIGHT_COLOUR, soundintensity = 0.1 },
}

--------------------------------------------------------------------------

local function MakeFire(name, fxlevels)
    local function GetHeatFn(inst)
        return 20
    end

    local function fn()
        local inst = CreateEntity()

        inst.entity:AddTransform()
        inst.entity:AddAnimState()
        inst.entity:AddSoundEmitter()
        inst.entity:AddNetwork()

        inst.AnimState:SetBank("campfire_fire")
        inst.AnimState:SetBuild("campfire_fire")
        inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
        inst.AnimState:SetRayTestOnBB(true)
        inst.AnimState:SetFinalOffset(3)

        inst:AddTag("FX")

        inst:AddTag("HASHEATER")

        inst.entity:SetPristine()

        if not TheWorld.ismastersim then
            return inst
        end

        inst:AddComponent("heater")
        inst.components.heater.heatfn = GetHeatFn

        inst:AddComponent("firefx")
        inst.components.firefx.levels = fxlevels
        if TheNet:GetServerGameMode() == "quagmire" then
            event_server_data("quagmire", "prefabs/campfirefire").master_postinit(inst)
        end
        inst.components.firefx:SetLevel(1)
        inst.components.firefx.usedayparamforsound = true

        return inst
    end

    return Prefab(name, fn, assets, prefabs)
end

return MakeFire("bboy_candlefire", candlefirelevels)
